class AddPostsColumn < ActiveRecord::Migration
  def self.up
    add_column :posts, :attachment_id, :string, :default => ""  #附件
    add_column :posts, :user_id, :integer, :default => 0      #发表者ID
    add_column :posts, :views_count, :integer, :default => 0  #查看次数
    add_column :posts, :comments_count, :integer, :default => 0 #计数器缓存，回复数    
    add_column :posts, :is_top, :integer, :default => 0       #是否是置顶
    add_column :posts, :remote_ip ,:string   , :default =>""               #IP地址
    add_column :posts, :visible ,:integer , :default => 1                  #可见性（0、1、2、3）
    add_column :posts, :close_comment ,:integer , :default => 0             #关闭评论（0、1）
    add_column :posts, :read_password ,:string, :default =>""               #阅读密码
  end
  
  def self.down
    remove_column :posts, :attachment_id, :string, :default => "" 
    remove_column :posts, :user_id, :integer, :default => 0      
    remove_column :posts, :views_count, :integer, :default => 0  
    remove_column :posts, :comments_count, :integer, :default => 0    
    remove_column :posts, :is_top, :integer, :default => 0       
    remove_column :posts, :remote_ip ,:string   , :default =>""  
    remove_column :posts, :visible ,:integer , :default => 1     
    remove_column :posts, :close_comment ,:integer , :default => 0
    remove_column :posts, :read_password ,:string, :default =>""  
  end
end
